package encore.web.listeners;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import encore.beans.BeanFactory;
import encore.beans.impl.SpringBeanFactory;
import encore.beans.test.Foo;
import encore.log.Logger;
import encore.log.LoggerFactory;

public class ContextLoaderListener implements ServletContextListener {

	private static Logger logger=LoggerFactory.getLogger(ContextLoaderListener.class);
	private static BeanFactory beanFactory;
	/**
	 * Listener 销毁
	 */
	public void contextDestroyed(ServletContextEvent event) {
	   logger.info("资源销毁……");
       
	}

	
	/**
	 * Listener 创建
	 */
	public void contextInitialized(ServletContextEvent event) {
	   logger.info("资源加载中……");
	   beanFactory=new SpringBeanFactory(event.getServletContext());
	   beanFactory.getBean("test",Foo.class).sayHello();
	}

}
